//
//  LoginViewController.m
//  Animation
//
//  Created by 陈亚勃 on 16/3/7.
//  Copyright © 2016年 cyb. All rights reserved.
//

#import "LoginViewController.h"

@interface LoginViewController ()

@end

@implementation LoginViewController

- (void)viewDidLoad {
    [super viewDidLoad];
}

- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];

    CGPoint usernameCenter = self.username.center;
    CGPoint passwordCenter = self.password.center;
    
    usernameCenter.x -= self.view.bounds.size.width;
    passwordCenter.x -= self.view.bounds.size.width;
    
    self.username.center = usernameCenter;
    self.password.center = passwordCenter;

    self.username.hidden = YES;
    self.password.hidden = YES;
}

- (void)viewDidAppear:(BOOL)animated{
    [super viewDidAppear:animated];
    
    self.username.hidden = NO;
    self.password.hidden = NO;
    
    [UIView animateWithDuration:0.3 delay:0 options:UIViewAnimationOptionCurveLinear animations:^{
        CGPoint usernameCenter = self.username.center;
        
        usernameCenter.x += self.view.bounds.size.width;
        
        self.username.center = usernameCenter;

    } completion:^(BOOL finished) {
        
    }];
    
    [UIView animateWithDuration:0.3 delay:0.1 options:UIViewAnimationOptionCurveLinear animations:^{
        CGPoint passwordCenter = self.password.center;
        
        passwordCenter.x += self.view.bounds.size.width;
        
        self.password.center = passwordCenter;

    } completion:^(BOOL finished) {
        
    }];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
